<?php

// redirect template to photos template
function wpsary_template() {
		
	$photoAlbumTitle = __('Photo Gallery');
	
	if (isset($_SERVER['WPSARY_REQUEST_URI'])) {

		
		$photoTemplate = 'error.html';
			
		$parts = explode('/', substr($_SERVER['WPSARY_REQUEST_URI'], strlen($_SERVER['REQUEST_URI'])));
		
		//album id
		$albumID = (int) $parts[1];

		//photo id
		$id = (int) $parts[2];

		add_action('wp_head', 'wpsary_header');
		add_action('wp_footer', 'wpsary_footer');

		add_filter('wp_title', get_option('wpsary_pagetitle'));

		if ($id > 0) {
			//photo info
			
			$photo = wpsary_getImageInfo($id);
			include(dirname(__FILE__) . '/photo.html');
		} elseif ($albumID > 0) {
			//album info & photo list

			$album = wpsary_getAlbumInfo($albumID);
			include(dirname(__FILE__) . '/album.html');

		} else {
			$albums = wpsary_getAlbumList();
			include(dirname(__FILE__) . '/index.html');

		}
		exit;
	} else {
		echo "Bad request";
	}
}



function wpsary_title($title) {
	Return $title;
}
function wpsary_header() {
	?>
<!-- header -->
	<?php
}

function wpsary_footer() {
	?>
<!-- footer -->
	<?php
}



?>
